/* __auth__ : KunLin */
package com.cskaoyan.controller;


import com.cskaoyan.bean.bo.goods.GoodsCreateBO;
import com.cskaoyan.bean.bo.goods.GoodsDeleteBo;
import com.cskaoyan.bean.bo.goods.GoodsListBO;
import com.cskaoyan.bean.bo.goods.GoodsUpdateBO;
import com.cskaoyan.bean.vo.goods.*;
import com.cskaoyan.service.GoodsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("admin/goods")
@RestController
public class GoodsController {


    @Autowired
    GoodsService goodsService;


    @RequiresPermissions(value = "admin:goods:list")
    @GetMapping("list")
    public GoodsListVO list(GoodsListBO goodsListBO){
        return goodsService.queryAllGoods(goodsListBO);
    }

    @GetMapping("catAndBrand")
    public GoodsCatAndBrandVO catAndBrand(){
        return goodsService.queryCategoryAndBrand();
    }

    @RequiresPermissions(value = "admin:goods:read")
    @GetMapping("detail")
    public GoodsDetailVO detail(Integer id){
        return goodsService.queryGoodsDetail(id);
    }

    @RequiresPermissions(value = "admin:goods:create")
    @PostMapping("create")
    public GoodsCreateVO create(@RequestBody GoodsCreateBO goodsCreateBO){
        return goodsService.create(goodsCreateBO);
    }

    @RequiresPermissions(value = "admin:goods:update")
    @PostMapping("update")
    public GoodsUpdateVO update(@RequestBody GoodsUpdateBO goodsUpdateBO){
        return goodsService.update(goodsUpdateBO);
    }

    @RequiresPermissions(value = "admin:goods:delete")
    @PostMapping("delete")
    public GoodsDeleteVo delete(@RequestBody GoodsDeleteBo goodsDeleteBo){
        return goodsService.delete(goodsDeleteBo);
    }
}
